package com.zk.utils;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * MD5编码
 * </p>
 *Shiro 安全组件
 * @author jyx
 * @since 2020-11-30
 */
public class VerityUtil {
    private final static String ALOGORITHNAME = "MD5";
    private final static int FREQUENCY= 2;

    public static Map<String, String> encrypted(String password) {
        Map<String, String> map = new HashMap<String, String>();
        String salt = new SecureRandomNumberGenerator().nextBytes().toHex();
        map.put("salt", salt);
        map.put("MD5password", new SimpleHash(ALOGORITHNAME, password, salt, FREQUENCY).toString());
        return map;


    }

    public static void main(String[] args) {
        System.out.println(encrypted("547463222jyx").toString());
    }

}
